package top.guxx.mall.config;

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

/**
 * @Author：Guxx
 * @Description：
 * @Date：2024/11/2 20:29
 * @Filename：GavaConfig
 */
@Configuration
public class GuavaConfig {
    @Bean(name = "wechatAccessToken")
    public Cache<String, String> wechatAccessToken(){
        return CacheBuilder.newBuilder()
                .expireAfterWrite(2, TimeUnit.HOURS)
                .build();
    }

    @Bean(name = "openidToken")
    public Cache<String, String> openidToken(){
        return CacheBuilder.newBuilder()
                .expireAfterWrite(1,TimeUnit.HOURS)
                .build();
    }
}
